        var map,layer,layer1,layer2,vlayer,tile,tiledGoogleStreet,tiled1GoogleState,osm,editroolBar,layerSwitcher,navigatorControl,panpaneControl,zoomPanelControl;
		var geocoder = null;
		// define a array to store the map layer
		var mapLayesArray = new Array();
		// defina a array to store the map overlayers
		var overlayArray = new Array();
		// pink tile avoidance
      OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
        // make OL compute scale according to WMS spec
      OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
        
		var isJsAddFeatures = false;// this var means, when we use js add the features, do not send message
		var isJsMapVoed = false;
		
		//  when as add to the map features save the feature from as add to the map.
		// when the javascript listener the add event, remove from the array
		var asAddArrs = [];
		var alreadyLayer = "";
		var alreadyis = true;
		
		//define a timer to show and hide
		//var cursorTime = window.setTimeout("somefunction",3000);
		// define a variable rember the mouse before point
		var mouseBefore = {};
		mouseBefore.x = 0;
		mouseBefore.y = 0;
		//define a variable which can show if the mouse is stop
		var isMouseMouveStop = true;
		//var closeCursorTime = window.setInterval("timeCursorFunction()",3000)

		//add a varailbe 
		var largerNameLength = 8;
        function init(){
			var divopen = document.getElementById("openLayersPanel");
			//divopen.visible = true;
			//var format = 'image/png';
			
			// var bounds = new OpenLayers.Bounds(
                //   -20037508.34,-20037508.34,20037508.34,20037508.34
              // );
               map = new OpenLayers.Map('map', {
			  	sprojection: new OpenLayers.Projection("EPSG:900913"),
			 	 displayProjection: new OpenLayers.Projection("EPSG:4326"),
			 	 units: "m",
			  	numZoomLevels: 20,
			 	 maxResolution: 200000.0339,
				maxExtent: new OpenLayers.Bounds(-10037508.34,-20037508.34,10037508.34,5037508.34)
			});
		
		
			tiledGoogleStreet = new OpenLayers.Layer.Google(
				"Google Streets", 
				{'sphericalMercator': true, numZoomLevels: 20}
			);
			 tiled1GoogleState = new OpenLayers.Layer.Google(
				"Google Satellite",
				{type: G_SATELLITE_MAP, 'sphericalMercator': true, numZoomLevels: 20}
			);
		
			
			 layer = new OpenLayers.Layer.WMS(
				   "LhrMajorRd",
				   "http://localhost:8085/geoserver/wms", 
				   { layers: "lahore",format:"image/png", transparent:true},
				   {opacity: '1', isBaseLayer: false,visibility: true}
				   );
				   
		
			layer2 =  new OpenLayers.Layer.WMS(
				   "Model Town",
				   "http://localhost:8085/geoserver/wms", 
				   { layers: "mt",format:"image/png", transparent:true},
				   {opacity: '1', isBaseLayer: false,visibility: true}
				   );
		layerBDGA = new OpenLayers.Layer.WMS(

				   "BDGA",

				   "http://www2.simal.ryerson.ca:7070/geoserver/cite/wms", 

				   { layers: "BDGA",format:"image/png", transparent:true},

				   {opacity: '1', isBaseLayer: false,visibility: true}

				);

			

		 layerADN = new OpenLayers.Layer.WMS(

				   "ADN_INTERNET_SECURITE_PUBLIQUE",

				   "http://www2.simal.ryerson.ca:7070/geoserver/cite/wms", 

				   { layers: "ADN_INTERNET_SECURITE_PUBLIQUE",format:"image/png", transparent:true},

				   {opacity: '1', isBaseLayer: false,visibility: true}

				);
		vlayer = new OpenLayers.Layer.Vector( "Editable" );
			//var container = document.getElementById("panel");
			
			editroolBar = new OpenLayers.Control.EditingToolbar(vlayer);
           map.addControl(editroolBar);
         
				   osm = new OpenLayers.Layer.OSM();
			layerSwitcher = new OpenLayers.Control.LayerSwitcher({'ascending':true});
			map.addControl(layerSwitcher);
			//map.addControl(new OpenLayers.Control.MousePosition());
			navigatorControl = new OpenLayers.Control.Navigation();
			map.addControl(navigatorControl);
			panpaneControl = new OpenLayers.Control.PanPanel();
			map.addControl(panpaneControl);
			
			zoomPanelControl = new OpenLayers.Control.ZoomPanel();
			map.addControl(zoomPanelControl);
       				// mapLayesArray only contains mapbase layer
					
					mapLayesArray.push(tiledGoogleStreet);
					mapLayesArray.push(tiled1GoogleState);
					
					mapLayesArray.push(osm);
					//mapLayesArray.push(layer);
					//mapLayesArray.push(layer2);
					//mapLayesArray.push(vlayer);
					//mapLayesArray.push(layerBDGA);
					//mapLayesArray.push(layerADN);
					//overlayArray.push(layer);
					//overlayArray.push(layer2);
					overlayArray.push(vlayer);
					overlayArray.push(layerBDGA);
					overlayArray.push(layerADN);
            map.addLayers([tiledGoogleStreet,tiled1GoogleState,osm,layerBDGA,layerADN,vlayer]);
			//map.addLayers([osm,layerBDGA,layerADN,vlayer]);
					//map.addOverlay(arcGISlayer);
				var center = new OpenLayers.LonLat(74.40, 31.15); 
				center.transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); 
				map.setCenter(center, 10);
				
			
       			 geocoder = new GClientGeocoder();
				 
				 
      
	
			//map register event
			map.events.register('moveend',this,onMoved);
			//map register a baselayer change event
			//map.events.register('changebaselayer', this, onBaseLayerChange);
			//register a featureadded listener to layers
			vlayer.events.register('featureadded', this,onfeatureadd);
			//vlayer.events.register('featuremodified', this,onfeatureModified);
			
			   //add the map changelayer event
               map.events.register("changelayer",this,onLayerChnage);
			
        }
		
		function onBaseLayerChange(obj){
			// catch the current layer, send to swf,
			try{
				var type = obj.layer.name;
				console.log(obj);
				thisMovie("MapSharingSimpleDemo").sendLayerChange(type);
			}catch(e){
				
			}
		}
		
		function onLayerChnage(e){
			var dd;
			try{
				//first we get the layer name, such as "BDGA"
				var layerName = e.layer.name;
				
				// second we get the layer visibility
				var visibility = e.layer.getVisibility();
			
				// if the layer alerady change ,do not change again
				if(layerName === alreadyLayer && visibility ===alreadyis)
				{
					//
				}else
				{
					// it the map base layer and the visiblit is  true				
					if(isNameOfMapBaseLayer(layerName)){
						if(visibility)
							thisMovie("MapSharingSimpleDemo").overLayserChange(layerName,visibility);
					}
					else{
						thisMovie("MapSharingSimpleDemo").overLayserChange(layerName,visibility);
					}
					
				}
				//send the data to the actionscript
				//thisMovie("MapSharingSimpleDemo").overLayserChange(layerName,visibility);
			}catch(e){
				
			}
		}
		
		function showAddress(address) {
		  if (geocoder) {
			geocoder.getLatLng(
			  address,
			  function(point){
				if (!point) {
				  alert(address + " not found");
				} else {
					var a = point.x;
				
					var b = point.y;
					
					var point = new OpenLayers.LonLat(a,b); 
					point.transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
				 	 map.setCenter(point,8);
				  
				}
			  }
			);
		  }
		}
		
		
		function onMoved(obj){
			//obj.object resprent the map objects
			
			if(isJsMapVoed)
			{
				isJsMapVoed = false;
				return;
			}
			var zoom = map.getZoom();
			var center = map.getCenter();
			//center.lat ,center.lon
			console.log("current zoom :" + zoom);
			console.log("center :" + center.lat + "," + center.lon);
			
			//send the data to the actionscript
			thisMovie("MapSharingSimpleDemo").sendMapChange(zoom,center);

		}

		
		function onfeatureadd(feature){
			//this means ,the layer add the featcure: vector,WFS. and must be Geometry,linearRing,lineString,Polygon and so on
			//first judge  weathe is it a Vector. feature.feature
			/*alert(OpenLayers.Feature.Vector.prototype.isPrototypeOf(feature.feature));
			alert(OpenLayers.Feature.prototype.isPrototypeOf(feature.feature));
			alert(OpenLayers.Feature.WFS.prototype.isPrototypeOf(feature.feature));
			alert(feature);*/
			if (isJsAddFeatures)
			{
				isJsAddFeatures = false;
				return;
			}
			if(OpenLayers.Feature.prototype.isPrototypeOf(feature.feature))
			{
				//OpenLayers.Feature.Vector instance
				if(OpenLayers.Feature.Vector.prototype.isPrototypeOf(feature.feature))
				{
					var geometryIns = feature.feature.geometry;
					// if featureId  exist in asAddArrs, do not send message 
					var featureId = geometryIns.id;
					var beinIndex = getFeatureIDIndex(featureId,asAddArrs);
					if(beinIndex != -1)
					{
						asAddArrs.shift(beinIndex,1);
						return;
					}
					if(OpenLayers.Geometry.prototype.isPrototypeOf(geometryIns))
					{
						//manager the serveral geometrys
						
						//OpenLayers.Geometry.LinearRing
						if(OpenLayers.Geometry.LinearRing.prototype.isPrototypeOf(geometryIns))
						{
							//thisMovie("MapSharingSimpleDemo").sendMapChange(zoom,center);
							console.log("LinearRing");
						}
						//OpenLayers.Geometry.LineString
						if(OpenLayers.Geometry.LineString.prototype.isPrototypeOf(geometryIns))
						{
							//save the  points
							var componets = geometryIns.components;
							var points = new Array();
							var index = 0;
							var item;
							for( item in componets)
							{
								var tempPoint = {};
								tempPoint.x = componets[item].x;
								tempPoint.y = componets[item].y;
								points[index] = tempPoint;
								index += 1;
							}
							//same time, get the features id, and to the message information
							var featureId = geometryIns.id;
							var obj = {};
							obj.points = points;
							obj.id = featureId;
							
	
							thisMovie("MapSharingSimpleDemo").sendDrawsFeature("OpenLayers.Geometry.LineString",obj);
						}
						//OpenLayers.Geometry.MultiLineString
						//OpenLayers.Geometry.MultiPoint
						//OpenLayers.Geometry.MultiPolygon
						//OpenLayers.Geometry.Point
						if(OpenLayers.Geometry.Point.prototype.isPrototypeOf(geometryIns))
						{
							//thisMovie("MapSharingSimpleDemo").sendMapChange(zoom,center);
							console.log("point");
							var points = new Array();
							
							var tempPoint = {};
								tempPoint.x = geometryIns.x;
								tempPoint.y =geometryIns.y;
								points.push(tempPoint);
							var obj = {};
							obj.id = geometryIns.id;
							obj.points = points;
							thisMovie("MapSharingSimpleDemo").sendDrawsFeature("OpenLayers.Geometry.Point",obj);
						}
						//OpenLayers.Geometry.Polygon
						if(OpenLayers.Geometry.Polygon.prototype.isPrototypeOf(geometryIns))
						{
							console.log("Polygon");
							//save the  linering
							//save the linering points
							var componets = geometryIns.components;
							
							
							var points = new Array();
							var index = 0;
							for( index in componets)
							{
								var newPoints = componets[index].components;
								var newDataPoints = new Array();
								var newIndex = 0;
								for (newIndex in newPoints)
								{
									var tempPoint = {};
									tempPoint.x = newPoints[newIndex].x;
									tempPoint.y = newPoints[newIndex].y;
									newDataPoints.push(tempPoint);
								}
								points.push(newDataPoints);
							}
							var obj = {};
							obj.id = geometryIns.id;
							obj.points = points;
							thisMovie("MapSharingSimpleDemo").sendDrawsFeature("OpenLayers.Geometry.Polygon",obj);
						}
						//OpenLayers.Geometry.Rectangle
					}else
					{
						console.log("wrong geometry");
					}
				}
				//OpenLayers.Feature.WFS instace
				if(OpenLayers.Feature.WFS.prototype.isPrototypeOf(feature.feature))
				{
				
				}
			}
			else
			{
				console.log("wrong fetaure");
			}
		}
		
		function onfeatureModified(feature){
			alert(feature);
		}
		//get the flash movie
       function thisMovie(movieName) {
         if (navigator.appName.indexOf("Microsoft") != -1) {
             return window[movieName];
         } else {
             return document[movieName];
         }
     }
	 // send the data to actionsctipt 
	 function sendDataToActionScript(value) {
		//thisMovie("applicationid") .applicationid means the swf name
         thisMovie("MapSharingSimpleDemo").sendDataToActionScript(value);
     }
	 
	 /*
	 when the flash message received ,call the javascipt method
	*/
	function asOpenaLayersChange(zoom,lon,lat){
		try{
			
			// set the extent null
			
			map.setOptions({restrictedExtent: null});
			
			
			console.log("actionscript make map moved ");
			//map.zoomTo(zoom);
			var lonNum = Number(lon);
			var latNum = Number(lat)
			var curLat = map.getCenter();
			var  currZoom = map.getZoom();
			if(currZoom == zoom && curLat.lon == lonNum && curLat.lat == latNum)
			{
				return;
			}
			
			var lonlat = new OpenLayers.LonLat(lonNum,latNum);
			// frist remove the eventlistener
			map.events.unregister('moveend',this,onMoved);
			map.setCenter(lonlat,parseInt(zoom),false,false);
			map.events.register('moveend',this,onMoved);
			// and add the eventlistener
			isJsMapVoed = true;
			
			//
			var curExt = map.getExtent();
			map.setOptions({restrictedExtent: curExt});
			
		}catch(e){
			alert(e);
		}
	}
	
	/*
	when the flash message receivde, call the javascript method
	type, the type is the openlayer featurs
	data, 
	*/
	function asOpenLayersDrawsFeature(type,data){
		try
		{
			console.log(type);
			console.log(data);
			var featureId = data.id;
			var oldFeatur =  vlayer.getFeatureById(featureId);
			//if exist?? do not add to the layer
			if(oldFeatur)
			{
				return;
			}
			switch(type)
			{
				case "OpenLayers.Geometry.Point":
				{
					
					var point = data.points[0];
					var pointTemp = new OpenLayers.Geometry.Point(point.x,point.y);
					var pointFeature = new OpenLayers.Feature.Vector(pointTemp);	
					asAddArrs.push(pointFeature.geometry.id);					
					vlayer.addFeatures([pointFeature]);
					
					
					break;
				}
				case "OpenLayers.Geometry.LineString":
				{
					var points = new Array();
					var index;
					for (index in data.points)
					{
						var obj1 = {};
						obj1 = data.points[index];
						var pointTemp = new OpenLayers.Geometry.Point(obj1.x,obj1.y);
						points.push(pointTemp);
					}
					var line = new OpenLayers.Geometry.LineString(points);

					var lineFeature = new OpenLayers.Feature.Vector(line);
					asAddArrs.push(lineFeature.geometry.id);
					vlayer.addFeatures([lineFeature]);
					isJsAddFeatures = true;
					console.log("js add a lineString ");
					
					
					break;
				}
				case "OpenLayers.Geometry.Polygon":
				{
					var index = 0;
					var lineStringArr = new Array();
					for (index in data.points)
					{
						var newIndex = 0;
						var newArrs = data.points[index];
						var pointsArr = new Array();
						for(newIndex in newArrs)
						{
							//points array
							var obj1 = {};
						    obj1 = newArrs[newIndex];
						    var pointTemp = new OpenLayers.Geometry.Point(obj1.x,obj1.y);
							pointsArr.push(pointTemp);
						}
						//close linearing
						pointsArr.push(pointsArr[0]);
						var line = new OpenLayers.Geometry.LinearRing(pointsArr);
						lineStringArr.push(line);
					}
					//var ploy = OpenLayers.Geometry.Polygon(lineStringArr);
					var ployFeature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon(lineStringArr));
					asAddArrs.push(ployFeature.geometry.id);
					vlayer.addFeatures([ployFeature]);
					console.log("js add a polygon");
					isJsAddFeatures = true;
					
					break;
				}
				default:
					break;
			}
		}catch(e)
		{
			alert(e);
		}
	}
		function btnBaseLayerClick()
		{
			setBaseLayer();
			//send the message
			var type = "base";
			thisMovie("MapSharingSimpleDemo").sendLayerChange(type);
		}
		
		function setBaseLayer()
		{
			layer.setVisibility(true);
			tiled1.setVisibility(false);
			map.setBaseLayer(layer);
			map.setOptions({theme: null});
			//send the message
		}
		
		function btnWMSClick()
		{

			setWMSLayer();
			var type = "wms";
			thisMovie("MapSharingSimpleDemo").sendLayerChange(type);
		}
		
		function setWMSLayer()
		{
			var bounds = new OpenLayers.Bounds(
                    -180, -90,
                    180, 90
                );
				var options = {
                    controls: [],
                    maxExtent: bounds,
                    maxResolution: 1.40625,
                    projection: "EPSG:4326",
                    units: 'degrees'
                };
			map.setOptions(options);
			layer.setVisibility(false);
			tiled1.setVisibility(true);
			map.setBaseLayer(tiled1);
		}
		
		// when receive the message,
		//Google Streets
		//all layers layer,tiled1,gphy, gmap, ghyb, gsat

		function asOpenaLayersBaseChange(type)
		{
			//first get the current layer, if layer is not the type, change 
			var currentLayerName = map.baseLayer.name;
			if(currentLayerName == type)
				return;
			setLayersVisable(type);
			
			//tempLayer.setVisibility(true);
		}
		
		// set the layer is visable true 
		function setLayersVisable(visalbeLayerName){
			var layersLength = mapLayesArray.length;
			for(var i = 0; i < layersLength; i ++){
				var tempLayer = mapLayesArray[i];
				if(tempLayer.name ==  visalbeLayerName){
				// if name is WmsLayer, it is special
						if(visalbeLayerName == "WmsLayer"){
							var bounds = new OpenLayers.Bounds(
							-180, -90,
							180, 90
						);
						var options = {
							controls: [],
							maxExtent: bounds,
							maxResolution: 1.40625,
							projection: "EPSG:4326",
							units: 'degrees'
						};
						map.setOptions(options);
					}else{
						map.setOptions({theme: null});
					}
					tempLayer.setVisibility(true);
					map.setBaseLayer(tempLayer);
				}else{
					tempLayer.setVisibility(false);
				}
			}
			
		}
		
		function getFeatureIDIndex(featureID,arrs)
		{
			var index = 0;
			var ret = -1;
			for(index in arrs)
			{
				if(featureID == arrs[index])
				{
					ret = index;
				}
			}
			return ret;
		}
		
		function asoverlayerChange(data){
			// fist set the map base layer
			var layerName = data.layerName;
			var vis = data.visb;
			alreadyLayer = layerName;
			alreadyis = vis;
			var currentLayerName = map.baseLayer.name;			
			if(currentLayerName == layerName)
				return;
				//if the base layer of map, than change 
			if(isNameOfMapBaseLayer(layerName) && vis ){
				// set the map base layer 
				for(var i = 0; i < mapLayesArray.length; i ++){
					var tempLayer = mapLayesArray[i];
					if(tempLayer.name ===  layerName){
					
						tempLayer.setVisibility(true);
						map.setBaseLayer(tempLayer);
					}
				}
			}
			setOverlayerVis(layerName,vis);
			// set the layerswitcher combox change or no check
			setTheinputContorol(layerName,vis);
			
			
		}
		
		function isNameOfMapBaseLayer(layerName){
			// whether the layer is map base layer
			// traverse the 
			for(var i = 0 ;i < mapLayesArray.length; i ++){
				var tempLayer = mapLayesArray[i];
				if(tempLayer.name === layerName)
					return true;
			}
			return false;
		}
		//set the overlayer 
		function setOverlayerVis(layerName,vis){
			var oversLength = overlayArray.length;
			for(var i =0;i < oversLength;i++){
				var tempOverlay = 	overlayArray[i];
				if(tempOverlay.name === layerName){
					tempOverlay.setVisibility(vis);
				}
			}
		}
		
		function setTheinputContorol(layerName,vis){
			// first get the all input control
			var alltgs = document.getElementsByTagName('input');
			var tagLength = alltgs.length;
			for(var i =0 ;i < tagLength; i ++){
				var tempInput = alltgs[i];
				// if the input control id containts layerName, 
				var tempInputId = tempInput.id;
				if(tempInputId.indexOf(layerName) != -1 ){
						// if true ,set the checkbox or radio checked
						//checked=true
						if(vis)
							tempInput.checked = true;
						else
							tempInput.removeAttribute("checked")
				}
			}
		}
		
		function openLayerShow(){
			//var divopen = document.getElementById("openLayersPanel");
			//divopen.visible = true;
		}
		
		// make the map div show
		function divShow(message){
			document.getElementById("openLayersPanel").style.display=""; 
			//#openLayersPanel {height:100%;width:100%}
			document.getElementById("openLayersPanel").style.height = "100%";
			document.getElementById("openLayersPanel").style.width = "100%";
			
			document.getElementById("bt").style.height = "300px";
			init();

		}
		
		// make the main  flash div show or hide
		function flashDivShow(condition){
			if(condition){
				document.getElementById("bt").style.height = "300px";
			}
			else{
				document.getElementById("bt").style.height = "50px";
			}
		}
		
		// add the browser close event
		  window.onbeforeunload = clean_up;   
      
		  function clean_up()   
		  {   
		  //var flex = document.${application} || window.${application};   
		   thisMovie("MapSharingSimpleDemo").sendtoActionScriptBrowserEvent("close");
		  }  

		// add the window onload method
		window.onload = initMove;
		
		// initMove is the onlaod method
		function initMove(){
			//add the mousemove to the document
			document.onmousemove = mouseMove;
		}
		
		//var isMouseMove = false;
		var cursorTimeOut;
		function mouseMove(ev){
			// get the mouse move instance
			ev = ev || window.event;
			// call mouseCoord method
			
			var mousePos = mouseCoord(ev);

			// when 
			//isMouseMove = true;
			//if the point in the rectangle 
			if(isPointInTheMap(mousePos)){
				// set the time out begin, if the three seconds later
				if(cursorTimeOut != null)
					window.clearTimeout(cursorTimeOut)
				cursorTimeOut = window.setTimeout("timeCursorFunction()",3000)
				//window.clearTimeout(t)

			    //if(isMouseMouveStop == false){
					// when we get the mouse is moved , we call the action script method, and precess the parameters
					thisMovie("MapSharingSimpleDemo").sendtoActionScriptMouseMove(mousePos);
				//}
			 }
		}
		
		function mouseCoord(ev){
			// if mouse event pageX or Pagey exist,
			// return the those
			if(ev.pageX || ev.pageY){  
        		return {x:ev.pageX, y:ev.pageY};  
			 }  
			 //else
			return {  
				 x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,  
				 y:ev.clientY + document.body.scrollTop   - document.body.clientTop  
			 }; 
		}
		// this is fucntion set the cursor div move
		function moveDiv(mousePos,username){
		
			if(isShowCursor) {
				var moveDiv = document.getElementById("mainCursor");
				var mainCursorTextDiv = document.getElementById("mainCursorText");
				if(username.length > largerNameLength)
				{
					username = reSetUserName(username);
				}
				mainCursorTextDiv.innerHTML =  username;
				//moveDiv.innerText  =  username;
				//show div
				moveDiv.style.display=""; 
				moveDiv.x = mousePos.x;
				moveDiv.y = mousePos.y;
				moveDiv.style.left = mousePos.x + 'px';
				moveDiv.style.top = mousePos.y + 'px';
			}
		}	
		
		// if the user name larget than 8 characters, add the whitespace to the string
		function reSetUserName(name){
			var retStr = "";
			for(var i = 0, length = name.length; i < length;i ++){
				if(i % (largerNameLength + 1) == 0){
					retStr = retStr + " ";
					retStr = retStr + name.charAt(i);
				}else{
					retStr = retStr + name.charAt(i);
				}
				
			}
			return retStr;
		}
		// this function is called by actionscipt
		function asexploerMouseMove(data){
			// data.point.x , point.y
			// data.userName move mouse user name
			moveDiv(data.point,data.userName);
		}
		
		// this function is judgement the point in the main map
		function isPointInTheMap(point){
			var ret = false;
			var divMap = document.getElementById("map");
			var rect = divMap.getBoundingClientRect();
			
			var top = {};
			top.x = rect.top;
			top.y = rect.left;
			
			var bottom = {};
			bottom.x = rect.right;
			bottom.y = rect.bottom;
			
			//console.log();
			
			if((point.x >= top.x && point.y <= bottom.x) && (point.y >= top.y && point.y <= bottom.y))
			{
				console.log("rectangle " + "  top: " + top.x + "," + top.y + "                   " + "bottomp:" + bottom.x + "," + bottom.y);
				console.log( "point " + point.x +"    " + point.y);
				
				
				ret = true;
			}
			return ret;
		}
		

		
		function stopTheCurosrTime(){
			window.clearInterval(closeCursorTime);
		}
		
		function timeCursorFunction(){
			// this is the function 
			//if the three seconds later, the cursor is stop ,then send the cursor stop message
			 thisMovie("MapSharingSimpleDemo").stoptheCursorSendToActionScript("stop");
		}
		
		function asStopTheCursor(value){
			disappearCursor();
		}
		
		function disappearCursor(){
			//if(isMouseMouveStop){
				// if the mouse is stop, disappear the cursor
				var moveDiv = document.getElementById("mainCursor");
				// hide the cursore
				moveDiv.style.display = "none"; 
			//}
		}
		
		function lockClick(){
			var para = document.getElementById("checkLock");
			if(para.checked){ 
				// checked
				// get the current map extend
				var curExtent = map.getExtent();
				/*if(map.restrictedExtent == null) {
					map.setOptions({restrictedExtent: curExtent});
					setTheEditorbarFalse();
					setTheLayerSwitchFalse();
				}*/
				var value = curExtent.toArray();
				thisMovie("MapSharingSimpleDemo").lockTheMapSendToActionScript(value);
			}else{
				// unchecked
				 /* map.setOptions({restrictedExtent: null});
				  setTheEditorbarTrue();
				  setTheLayerSwitchTrue();*/
				  thisMovie("MapSharingSimpleDemo").unlockTheMapSendToActionscript();
			}
		}
		
		function setTheEditorbarFalse(){			
			var editorBarid = editroolBar.id;
			var editorBarDiv = document.getElementById(editorBarid);
			editorBarDiv.style.display = "none";
		}
		
		function setTheEditorbarTrue(){
			
			var editorBarid = editroolBar.id;
			var editorBarDiv = document.getElementById(editorBarid);
			editorBarDiv.style.display = "";
		}
		
		function setTheLayerSwitchFalse(){
			var switchId = layerSwitcher.id;
			var switcher = document.getElementById(switchId);
			switcher.style.display = "none";
		}
		
		function setTheLayerSwitchTrue(){
			var switchId = layerSwitcher.id;
			var switcher = document.getElementById(switchId);
			switcher.style.display = "";
		}
		
		function setnavigatorControlTrue(){
			var naid = navigatorControl.id;
			var nacontrl = document.getElementById(naid);
			nacontrl.style.display = "";
		}
		function setnavigatorControlFalse(){
			var naid = navigatorControl.id;
			var nacontrl = document.getElementById(naid);
			nacontrl.style.display = "none";
		}
		
		function setpanpaneControlTrue(){
			var panID = panpaneControl.id;
			var nacontrl = document.getElementById(panID);
			nacontrl.style.display = "";
		}
		function setpanpaneControlFalse(){
			var panID = panpaneControl.id;
			var nacontrl = document.getElementById(panID);
			nacontrl.style.display = "none";
		}
		
		function setzoomPanelControlTrue(){
			var zoomID = zoomPanelControl.id;
			var nacontrl = document.getElementById(zoomID);
			nacontrl.style.display = "";
		}
		
		function setzoomPanelControlFalse(){
			var zoomID = zoomPanelControl.id;
			var nacontrl = document.getElementById(zoomID);
			nacontrl.style.display = "none";
		}
		function setPanlZoomControlTrue(){
			// first get the all div control
			var alltgs = document.getElementsByTagName('div');
			var tagLength = alltgs.length;
			for(var i =0 ;i < tagLength; i ++){
				var tempInput = alltgs[i];
				// if the input control id containts OpenLayers.Control.PanZoom_, 
				var tempInputId = tempInput.id;
				if(tempInputId.indexOf("OpenLayers.Control.PanZoom_") != -1 ){
						tempInput.style.display = "";
				}
			}
		}
		
		function setPanlZoomControlFalse(){
			// first get the all div control
			var alltgs = document.getElementsByTagName('div');
			var tagLength = alltgs.length;
			for(var i =0 ;i < tagLength; i ++){
				var tempInput = alltgs[i];
				// if the input control id containts OpenLayers.Control.PanZoom_, 
				var tempInputId = tempInput.id;
				if(tempInputId.indexOf("OpenLayers.Control.PanZoom_") != -1 ){
						tempInput.style.display = "none";
				}
			}
		}
		
		function setTheMapPanelFalse(){
			var mapdiv = document.getElementById("map");
			//mapdiv.disabled = false;
			mapdiv.ondragstart = function(){return false;}
			mapdiv.onclick = function(){return false;}
		}
		
		
		function setTheMapPanelTrue(){
			var mapdiv = document.getElementById("map");
			//mapdiv.disabled = true;
			mapdiv.ondragstart = function(){return true;}
			mapdiv.onclick = function(){return true;}
		}
		
		function asLockTheMap(value){
			var left = value[0];
			var bottom = value[1];
			var right = value[2];
			var top = value[3];
			var bounds = new OpenLayers.Bounds(left,bottom,right,top);
			
			// get the current map extent
			var curExtent = map.getExtent();		
			map.setOptions({restrictedExtent: curExtent});
			
			//setTheMapPanelFalse();
			setTheEditorbarFalse();
			setTheLayerSwitchFalse();
			//setnavigatorControlFalse();
			setPanlZoomControlFalse();
			setpanpaneControlFalse();
			setzoomPanelControlFalse();
			// disable the checkLock
			var para = document.getElementById("checkLock");
			para.disabled = true;
			para.checked = true;
			
		}
		
		function asUnLockTheMap(){
			
			map.setOptions({restrictedExtent: null});
			//setTheMapPanelTrue();
			setTheEditorbarTrue();
			setTheLayerSwitchTrue();
			//setnavigatorControlTrue();
			setPanlZoomControlTrue();
			setpanpaneControlTrue();
			setzoomPanelControlTrue();
			// enable the checklock
			var para = document.getElementById("checkLock");
			para.disabled = false;
			para.checked = false;
		}
		
		/// add a function ,to show all user cursor in the map
		function showCursorToAll(){
			
			// send the message to actionscript
			
			thisMovie("MapSharingSimpleDemo").showallcursorToAactionScript(true)
		}
		
		function DisapperCursorToAll(){
			// send the message to actionscript
			
			thisMovie("MapSharingSimpleDemo").showallcursorToAactionScript(false)
		}
		
		// the default showCursor is false
		var isShowCursor = false;
		function asshowAllCursor(data){
			if(data.isShow)
				isShowCursor = true;
			else
				isShowCursor = false;
		}